-------------------------------------------------------------------------------
-- script_runner
-------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION script_runner (
	func_body TEXT
) 
RETURNS void AS $body$
DECLARE
func_cmd text;
BEGIN
	func_cmd := 
		'CREATE FUNCTION temp_script() RETURNS void AS '
		|| quote_literal(func_body)
		|| ' VOLATILE LANGUAGE plpgsql;' ;
	EXECUTE func_cmd;
	EXECUTE 'SELECT temp_script();';
	EXECUTE 'DROP FUNCTION temp_script();';
	RETURN;	
END;
$body$ LANGUAGE 'plpgsql' VOLATILE;

